using Godot;
using System;
using Library;

namespace DRE {
	public class Manager : Control {
		Manager() {
			Instance = this;
		}
		public struct UICollection {
			public UICollection(Fader fader, UIGroup overFader, UIGroup underFader) {
				Fader = fader;
				OverFader = overFader;
				UnderFader = underFader;
			}
			public Fader Fader { get; }
			public UIGroup OverFader { get; }
			public UIGroup UnderFader { get; }
		}
		public struct UIGroup {
			public UIGroup(Control persisted, Control sceneWise) {
				Persisted = persisted;
				SceneWise = sceneWise;
			}
			public Control Persisted { get; }
			public Control SceneWise { get; }
		}

		public static Manager Instance { get; private set; }
		//Nodes
		public static CameraController2D Camera { get; private set; }
		public static MusicController Music { get; private set; }

		//Others
		public static UICollection UI { get; private set; }
		public static StorageManager Storages { get; } = new StorageManager();
		public static Inventory Inventory { get; } = new Inventory();
		public static Item.Manager Items { get; } = new Item.Manager();
		public static Character.Manager Characters { get; } = new Character.Manager();
		public static Character.SpellManager CharacterSpells = new Character.SpellManager();
		public static Character.StatsItemManager CharacterStatsItems = new Character.StatsItemManager();

		public static Random Random { get; } = new Random();

		public override void _Ready() {
			Camera = GetNode<CameraController2D>("Camera2D");
			Music = GetNode<MusicController>("Music");

			Fader fader = GetNode<Fader>("UI/Fader");
			UIGroup overFaderUI = new UIGroup(GetNode<Control>("UI/OverFader/Persisted"), GetNode<Control>("UI/OverFader/SceneWise"));
			UIGroup underFaderUI = new UIGroup(GetNode<Control>("UI/UnderFader/Persisted"), GetNode<Control>("UI/UnderFader/SceneWise"));
			UI = new UICollection(fader, overFaderUI, underFaderUI);
		}
	}
}
